<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', 'PagesController@root')->name('root');

/**
 * 用户认证路由
 * Auth::routes(); 方便起见，写为下面的样子
 */
// Authentication Routes...
Route::get('login', 'Auth\LoginController@showLoginForm')->name('login');
Route::post('login', 'Auth\LoginController@login');
Route::post('logout', 'Auth\LoginController@logout')->name('logout');

// Registration Routes...
Route::get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
Route::post('register', 'Auth\RegisterController@register');

// Password Reset Routes...
Route::get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
Route::post('password/reset', 'Auth\ResetPasswordController@reset');

//用户路由
Route::resource('users', 'UsersController', ['only' => ['show', 'update', 'edit']]);

/**
 * 话题路由
 */
Route::resource('topics', 'TopicsController', ['only' => ['index', 'create', 'store', 'update', 'edit', 'destroy']]);
Route::get('/topics/{topic}/{slug?}', 'TopicsController@show')->name('topics.show');
//测试路由，发布后删除
Route::get('/test', 'TestController@root');
//分类路由
Route::resource('/categories', 'CategoriesController');
//上传图片
Route::post('upload_image', 'TopicsController@uploadImage')->name('topics.upload_image');
//话题回复
Route::resource('replies', 'RepliesController', ['only' => ['store', 'destroy']]);
//消息通知
Route::resource('notifications', 'NotificationsController', ["only" => ['index']]);

/**
 * 后台管理
 */
Route::group(['namespace' => 'Admin', 'prefix' => 'admin'], function () {
    //index
    Route::get('/', 'HomePageController@index')->name('admin.index');
    //topics_edit
    Route::get('/topics', 'HomePageController@edit_topics')->name('admin.topics');
});